﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>WebSocket Test</title>
    <script language="javascript" type="text/javascript">
        var wsUri = "ws://localhost:10270";
        var output;

        function init() {
            output = document.getElementById("output");

            document.getElementById('connect').onclick = function (e) {
                testWebSocket();
            };
        }

        function testWebSocket() {
            websocket = new WebSocket(wsUri);
            websocket.onopen = function (evt) {
                onOpen(evt)
            };
            websocket.onclose = function (evt) {
                onClose(evt)
            };
            websocket.onmessage = function (evt) {
                onMessage(evt)
            };
            websocket.onerror = function (evt) {
                onError(evt)
            };
        }

        function onOpen(evt) {
            writeToScreen("CONNECTED");
            //var data = { "OptType": 6, "FilePath": "8e98d24306bd4ec4b154b0294fab0cae.doc", "DocCode": "testdoccode" }
            data = {

                "id": "8c1a3a94c69d45c89ab0346066d4dee6",
                "optType": "0",
                "FilePath": "http://localhost:5276/t.doc",
                "docCode": "0ff13bf3171445f69a1739f3651c745c",
                "token": "f11df57a2dcc71048765e0db74d3d395",
                "FileVersion": 1,
                "IsReadOnly": false,
                "user": "admin", "uploadPath": "http://localhost:8080/OA_P0003/Middle/ywUploadM"

            }
            //    data =
            //            {
            //        "id": "e9e0fb61d40c4d09b6e821fa23c79ac4",
            //            "optType": "4",
            //            "filePathExt": ["http://localhost:8080/OA_P0003/Middle/downloadFile?docCode=1f49247a56434d83bec98bf0e1d8eb52&fyck=officeMiddle&filePath=1f49247a56434d83bec98bf0e1d8eb52.doc", "http://localhost:8080/OA_P0003/Middle/downloadFile?docCode=7f856288b1f24285a7ffb6974c955e20&fyck=officeMiddle&filePath=7f856288b1f24285a7ffb6974c955e20.doc"], "redPath": "http://localhost:8080/OA_P0003/Middle/downloadFile?filePath=yygzzbgl\\通用周报.doc",
            //                "verPath": "http://localhost:8080/OA_P0003/Middle/downloadFile?filePath=yygzzbgl\\通用周报版记.doc", "copyHeader": false, "openType": "0", "params": "{'￥￥Stdept':'其他','￥￥Number':'3','￥￥ConterNumber':'423','￥￥cdate':'2023年7月17日-7月23日','￥￥fs':'办公室','￥￥sj':'2023年7月18日'}", "user": "admin", "docCode": "31b55bf88e6846e784c4e2a7c2d31fcb", "sessionID": "9EACE9C8968241ADB0FDD2A073BB33C4", "token": "f11df57a2dcc71048765e0db74d3d395",
            //            "uploadPath": "http://localhost:8080/OA_P0003/Middle/ywUploadM"

            //}
            //data = { "OptType": 6, "FilePath": "8e98d24306bd4ec4b154b0294fab0cae.doc" }

            //data = {
            //    "Id": "e877580600154d219f9287ecd3f593c1",
            //    "OptType": 8,
            //    "FilePath": "http://localhost:5276/abc.xlsx",
            //    "RedPath": "http://localhost:5276/工作联系单.doc",
            //    "VerPath": "http://localhost:5276/a3.doc",
            //    "OpenType": 0,
            //    "Params": "{'￥￥Dta':'二零二三','￥￥mtype':'','￥￥mlevel':'','￥￥hlevel':'','￥￥title':'中建投办签','￥￥year':'2023','￥￥number':'1','￥￥subject':'cc-qb-2023-01-009','￥￥cbr':'123','￥￥fujian':'','￥￥cdate':'2023年1月9日','￥￥fjbt':'','￥￥ngbm':'其他'}", "User": "admin", "DocCode": "fbed40f1595c42e7b0c05246e8465f02", "IsForce": false,
            //    "SessionId": "993EA213005C3DF17CA02D9EA432E6BA",
            //    "Token": "f11df57a2dcc71048765e0db74d3d395",
            //    "UploadPath": "http://localhost:5000/home/upload",
            //    "FileName": null, "FileDirectory": null,
            //    "IsReadOnly": false,
            //    "CopyHeader": true
            //}
            doSend(JSON.stringify(data));

            //doSend(JSON.stringify({
            //    "OptType": 7,
            //    "FilePath": "http://localhost:5276/wordTemplate.DOC",
            //    "RedPath": "http://localhost:5276/ht.DOC",
            //    "VerPath": "http://localhost:5276/bj.DOC",
            //    "OpenType": 0,
            //    "Params": "{'￥￥FYTFS':'议题1'}",
            //    "User": "com.lm.web.entity.user.AppUser@6fcf2f86",
            //    "DocCode": "testdoccode",
            //    "SessionId": "75F38BDBC6BFEE57F48A1CF54616FCA3",
            //    "Token": "f11df57a2dcc71048765e0db74d3d395",
            //    "UploadPath": "http://127.0.0.1:5276/home/upload",
            //    "FileName": "这是一个测试1.txt"
            //}));

            //doSend(JSON.stringify({
            //    "OptType": 7,
            //    "FilePath": "http://localhost:5276/wordTemplate.DOC",
            //    "RedPath": "http://localhost:5276/ht.DOC",
            //    "VerPath": "http://localhost:5276/bj.DOC",
            //    "OpenType": 0,
            //    "Params": "{'￥￥FYTFS':'议题1'}",
            //    "User": "com.lm.web.entity.user.AppUser@6fcf2f86",
            //    "DocCode": "testdoccode",
            //    "SessionId": "75F38BDBC6BFEE57F48A1CF54616FCA3",
            //    "Token": "f11df57a2dcc71048765e0db74d3d395",
            //    "UploadPath": "http://127.0.0.1:5276/home/upload",
            //    "FileName": "这是一个测试2.txt"
            //}));
        }

        function onClose(evt) {
            writeToScreen("DISCONNECTED");
        }

        function onMessage(evt) {
            writeToScreen('<span style="color: blue;">RESPONSE: ' + evt.data + '</span>');
            websocket.close();
        }

        function onError(evt) {
            writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
        }

        function doSend(message) {
            writeToScreen("SENT: " + message);
            websocket.send(message);
        }

        function writeToScreen(message) {
            var pre = document.createElement("p");
            pre.style.wordWrap = "break-word";
            pre.innerHTML = message;
            output.appendChild(pre);
        }
        window.addEventListener("load", init, false);
    </script>
</head>
<body>
    <h2>WebSocket Test</h2>
    <input type="button" id="connect" value="连接WebSocket" />
    <div id="output"></div>
</body>
</html>
<script>

</script>